require(["./config"], () => {
    require(["template","url","header","footer","main","fly"], (template,url) =>{
        class Register {
            constructor () {
               this.registerHr()
            }
            registerHr () {
                // var username = document.querySelector('#username').value 
                // var password = document.querySelector('#password').value;
                $("form").submit( function () {
                    return false;
                  } );
                 
                this.ways();
            }
            ways () {
                //判断是否注册过 是否有数据
                $("button").on("click", (e) => {
                    var username = document.querySelector('#username').value 
                    var password = document.querySelector('#password').value;
                    let userinfo = { username, password };
                    let userList = localStorage.getItem('userList');
                    
                    if (userList) {
                        userList = JSON.parse(userList)
                        userList.push(userinfo)
                        localStorage.setItem('userList', JSON.stringify(userList))
                        console.log(userList)
                    } else {
                        var arr = [ userinfo ]
                        localStorage.setItem('userList', JSON.stringify(arr))
                    }

                    alert('注册成功，即将跳转登录界面')
                    location.replace ("/html/login.html") 
                })
            }
        }
        new Register()
    })
})